﻿using System.Collections.Generic;

namespace HamcoWcs.Models.Common
{
    /// <summary>
    /// 前端基础返回值
    /// </summary>
    public class ForeEndResult
    {
        private static ForeEndResult OK_RESULT = new ForeEndResult();

        public ForeEndResult()
        {
            Code = 200;
            Details = "ok";
        }

        public ForeEndResult(object data) : this()
        {
            Data = data;
        }

        public ForeEndResult(object data, int count, int pageCount) : this()
        {
            Data = data;
            Count = count;
            PageCount = pageCount;
        }

        public int Code { get; set; }
        public string Details { get; set; }
        public object? Data { get; set; }
        public int? Count { get; set; }
        public int? PageCount { get; set; }

        public static ForeEndResult Ok => OK_RESULT;
        public static ForeEndResult Fail(string msg) => new ForeEndResult() { Code = 0, Details = msg };

    }

    ///// <summary>
    ///// 前端带数据的返回值
    ///// </summary>
    //public class ForeEndDataResult : ForeEndResult
    //{
    //    public object Data { get; set; }
    //    public ForeEndDataResult(object data)
    //    {
    //        Data = data;
    //    }
    //}

    public class ForeEndListResult<T> : ForeEndResult where T : class, new()
    {
        public ForeEndListResult(List<T> data)
        {
            Data = data;
        }

        public new List<T> Data { get; set; }
    }


    public class PageResult<T> : ForeEndListResult<T> where T : class, new()
    {

        public PageResult(int count, int pageCount, List<T> data) : base(data)
        {
            Count = count;
            PageCount = pageCount;
        }

        public int Count { get; set; }
        public int PageCount { get; set; }
    }
}
